using UnityEngine;
using UnityEditor;
using System.Collections;

public class ShowSize : EditorWindow
{
	static ShowSize sizeWindow;
	
	[MenuItem("Window/ShowSize")]
	static void Init()
	{
		sizeWindow = new ShowSize();
		sizeWindow.autoRepaintOnSceneChange = true;
		sizeWindow.Show();
	}
	
	void OnGUI()
	{
		GameObject selected = Selection.activeObject as GameObject;
		if(selected == null)
			return;
		
		MeshFilter mf = selected.GetComponent<MeshFilter>();
		if(mf == null)
			return;
		
		Mesh mesh = mf.sharedMesh;
		if(mesh == null)
			return;
		
		Vector3 size = mesh.bounds.size;
		Vector3 scale = selected.transform.localScale;
		
		
		GUILayout.BeginArea(new Rect(0,0,320,240));
		GUILayout.Label("Size\nX: " + size.x * scale.x + 
						"   Y: " + size.y * scale.y + 
						"   Z: " + size.z * scale.z);
		
		GUILayout.BeginHorizontal();
		
		if(GUILayout.Button("Test"))
		{
			Debug.Log("Test");
		}
		if(GUILayout.Button("Test2"))
		{
			Debug.Log("Test2");
		}
		GUILayout.EndHorizontal();
		GUILayout.EndArea();
		
	}
	
	void OnInspectorUpdate()
	{
		Repaint();
	}
}
